package cn.brilliantfuture.commentry.entity;

// Generated 2011-11-3 13:34:34 by Hibernate Tools 3.3.0.GA

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Community generated by hbm2java
 */
@Entity
@Table(name = "community", catalog = "cabinet")
public class Community implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer communityId;
	private Level level;
	private String name;
	private String description;
	private boolean deleted;
	private Set<CommunityRole> communityRoles = new HashSet<CommunityRole>(0);
	private Set<User> users = new HashSet<User>(0);

	public Community() {
	}

	public Community(Level level, String name, boolean deleted) {
		this.level = level;
		this.name = name;
		this.deleted = deleted;
	}

	public Community(Level level, String name, String description,
			boolean deleted, Set<CommunityRole> communityRoles, Set<User> users) {
		this.level = level;
		this.name = name;
		this.description = description;
		this.deleted = deleted;
		this.communityRoles = communityRoles;
		this.users = users;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "community_id", unique = true, nullable = false)
	public Integer getCommunityId() {
		return this.communityId;
	}

	public void setCommunityId(Integer communityId) {
		this.communityId = communityId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "fk_level_id", nullable = false)
	@NotNull
	public Level getLevel() {
		return this.level;
	}

	public void setLevel(Level level) {
		this.level = level;
	}

	@Column(name = "name", nullable = false, length = 45)
	@NotNull
	@Length(max = 45)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "description", length = 45)
	@Length(max = 45)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "deleted", nullable = false)
	public boolean isDeleted() {
		return this.deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "community")
	public Set<CommunityRole> getCommunityRoles() {
		return this.communityRoles;
	}

	public void setCommunityRoles(Set<CommunityRole> communityRoles) {
		this.communityRoles = communityRoles;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "community")
	public Set<User> getUsers() {
		return this.users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

}
